<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> Login </title>
<link rel="stylesheet" type="text/css" href="style.css"/>
</head>

<body>
<?php
include 'config.php';

session_start();
$login_user = "";
if($_SERVER["REQUEST_METHOD"] == "POST")
{
	$myusername=addslashes($_POST['username']);
	$mypassword=addslashes($_POST['password']);
	
	$sql="SELECT id FROM users WHERE username='".$myusername."' and password='".$mypassword."'";

	$result = mysql_query($sql);
	
	if($result === FALSE) {
		//header("location: error.php"); // open this for runtime to avoid vulnerability
		die(mysql_error()); // keep this for development time only.
		return;
	}
	
	$result=mysql_query($sql);	
	$row=mysql_fetch_array($result);
	$active=$row['id'];
	$count=mysql_num_rows($result);
		
	if($count==1)
	{
		$_SESSION['login_user']=$myusername;
		
		//header("location: welcome.php");	
		header("location: profile.php");
		//echo "Successful Login";
	}
	else
	{
		$error="Your Login Name or Password is invalid ";
		echo $error;
	}
}
?>
<?php
include ("Master\head.html");
?>
<!-- Table for Main Body -->
<table border="0" width="70%" cellspacing="0" cellpadding="2" align="center">
<tr>
<td valign="top" align="left" width="60">
<a href="home.php">Home</a><?php echo "<div>\n"; ?>
<a href="Login.php">Login</a><?php echo "<div>\n"; ?>
<a href="register.php">Register</a><?php echo "<div>\n"; ?>
<a href="contactus.php">Contact Us</a>

</td>
<td width="1" bgcolor="lightskyblue" valign="top">  </td>
<td width="377" valign="top">
<h2> Login </h2>
<form action="" method="post">
<label>UserName :</label>
<input type="text" name="username"/><br />
<label>Password :</label>
<input type="password" name="password"/><br/>
<input type="submit" value=" Submit "/><br />
</form>
<br> <br>
<?php
include ("Master\menu.html");
?>
</td>
<td width="1" bgcolor="lightskyblue" valign="top">   </td>
</tr></table>

</body></html>